﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PepsiCo.Business
{
    public partial class pepsi_Staff
    {
        public static bool CheckExistsStaffCode(Guid? staffId, string staffCode)
        {
            using (PepsiCoDBDataContext db = new PepsiCoDBDataContext(LocalSetting.ConnectionString))
            {
                if (staffId == null)
                {
                    if (db.pepsi_Staffs.Any(p => p.StaffCode == staffCode))
                        return true;
                }
                else
                {
                    if (db.pepsi_Staffs.Any(p => p.StaffCode == staffCode && p.StaffID != staffId))
                        return true;
                }
                return false;
            }
        }
    }
}
